Completed
Push — master ( e9e0b4...cbda97 )
by J.D.
03:49
created

module.exports   C

Complexity

Conditions 7
Paths 11

Size

Total Lines 88

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
nc 11
nop 2
dl 0
loc 88
rs 6.5184
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
/**
2
 * Grunt configuration file.
3
 *
4
 * @package WordPoints
5
 * @since 2.1.0
6
 */
7
8
/* jshint node:true */
9
module.exports = function( grunt ) {
10
11
	// Load the default configuration from the dev-lib.
12
	require( './dev-lib/grunt/modules/configure.js' )( grunt, __dirname );
13
14
	// Project configuration.
15
	grunt.config(
16
		[ 'autoloader', 'all', 'filter' ]
17
		, function ( class_files, class_dir ) {
18
19
			if ( 'src/components/points/classes/' === class_dir ) {
20
21
				// This class needs to come before other entity restriction classes.
22
				class_files.splice(
23
					class_files.indexOf( 'logs/viewing/restrictioni.php' ) + 1
24
					, 0
25
					, class_files.splice(
26
						class_files.indexOf( 'logs/viewing/restriction/post/status/nonpublic.php' )
27
						, 1
28
					)[0]
29
				);
30
31
			} else if ( 'src/classes/' !== class_dir ) {
32
				return class_files;
33
			}
34
35
			var entity_parents = [],
36
				action_parents = [];
37
38
			// Extract the parent class files. To do that we need to loop
39
			// backwards so that we can remove elements from the array as we go.
40
			for ( var i = class_files.length - 1; i >= 0; i-- ) {
41
42
				if ( class_files[ i ].substr( 0, 14 ) === 'entity/stored/' ) {
43
44
					entity_parents.push( class_files[ i ] );
45
					class_files.splice( i, 1 );
46
47
				} else if ( class_files[ i ].substr( 0, 19 ) === 'entity/relationship' ) {
48
49
					entity_parents.push( class_files[ i ] );
50
					class_files.splice( i, 1 );
51
52
				} else if ( class_files[ i ].substr( 0, 21 ) === 'hook/action/post/type' ) {
53
54
					action_parents.push( class_files[ i ] );
55
					class_files.splice( i, 1 );
56
				}
57
			}
58
59
			// Entity these entity classes need to come before other entity classes.
60
			Array.prototype.splice.apply(
61
				class_files
62
				, [ class_files.indexOf( 'entity.php' ) + 1, 0 ]
63
					.concat( entity_parents.reverse() )
64
			);
65
66
			// Entityish class needs to come before the entity classes.
67
			class_files.splice(
68
				class_files.indexOf( 'entity.php' )
69
				, 0
70
				, class_files.splice(
71
					class_files.indexOf( 'entityish.php' )
72
					, 1
73
				)[0]
74
			);
75
76
			// This class needs to come before other entity restriction classes.
77
			class_files.splice(
78
				class_files.indexOf( 'entity/restrictioni.php' ) + 1
79
				, 0
80
				, class_files.splice(
81
					class_files.indexOf( 'entity/restriction/post/status/nonpublic.php' )
82
					, 1
83
				)[0]
84
			);
85
86
			// Action classes that need to come before other action classes.
87
			Array.prototype.splice.apply(
88
				class_files
89
				, [ class_files.indexOf( 'hook/action.php' ) + 1, 0 ]
90
					.concat( action_parents.reverse() )
91
			);
92
93
			// This class needs to come before other event classes.
94
			class_files.splice(
95
				class_files.indexOf( 'hook/event.php' ) + 1
96
				, 0
97
				, class_files.splice(
98
					class_files.indexOf( 'hook/event/dynamic.php' )
99
					, 1
100
				)[0]
101
			);
102
103
			return class_files;
104
		}
105
	);
106
};
107
108
// EOF
109